import { defineStore } from 'pinia'
import { EncryptStorage } from "encrypt-storage";
//需注意使用stateManagementUse
export const encryptStorage = new EncryptStorage("YM1234567890", {
  stateManagementUse: true,
});
export interface Search {
    searchValue: string

}

export const useSearch = defineStore('Search', {
    state: (): Search => {
        return {
            searchValue: '',
          
        }
    },
    actions: {
        setSearchValue(value:string) {
            this.searchValue = value;
        },
        clearSearchValue() {
            this.searchValue = ''; // 清空 searchValue
        },
    },
    persist: {
        enabled: true,
        key: "Search", //如果需要对存储的密钥key进行命名
        storage: encryptStorage,
        // storage: localStorage, //如果不使用加密处理
        paths: ["Search"],
    },
})